package database;

import java.sql.*;

import oracle.jdbc.pool.OracleDataSource;


public class ForgotOperations {

	private Connection conn;
	private Statement stm;
	private ResultSet rst;
	private PreparedStatement prst;
	
	public ForgotOperations() {
		
		conn=openDB();
	}
	
	// open database connection
	public Connection openDB() {
		
		try {
			
			OracleDataSource ods = new OracleDataSource();

			if ( test.Main.dataConn == "GaryTallaght"){
				ods.setURL("jdbc:oracle:thin:@//10.10.2.7:1521/global1");
				ods.setUser("X00106491");
				ods.setPassword("db13May85");
			}
			else if ( test.Main.dataConn == "KeythTallaght"){
				ods.setURL("jdbc:oracle:thin:@//10.10.2.7:1521/global1");
				ods.setUser("X00106271");
				ods.setPassword("db19Jan82");
			}
			else if ( test.Main.dataConn == "KeythHome"){
				ods.setURL("jdbc:oracle:thin:HR/localhost:1521:XE");
				ods.setUser("System");
				ods.setPassword("7481600kW");
			}
			else if ( test.Main.dataConn == "GaryHome"){
				ods.setURL("jdbc:oracle:thin:HR/SYSTEM@localhost:1521:XE");
				ods.setUser("SYSTEM");
				ods.setPassword("1nf1n1ty");
			}
			
			conn = ods.getConnection();
			System.out.println("connected forgot.");
		} 
		catch (Exception e) {
			
			System.out.print("Unable to load driver " + e);
			System.exit(1);
		}
		return conn;
	}
	
	
	

	// close the connection to database
		public void closeDB() {
			try {
				stm.close();
				rst.close();
				conn.close();
				System.out.print("Connection closed forgot");
			} 
			catch (SQLException e){
				System.out.print("Could not close connection ");
				e.printStackTrace();
			}
		}
}
